// 用户相关类型
export interface User {
  id: number
  email: string
  nickname: string
  avatar?: string
  role?: 'super_admin' | 'admin' | 'editor' | 'user'
  subscriptionType: 'free' | 'basic' | 'premium'
  subscriptionEndDate?: string
  createdAt?: string
  updatedAt?: string
}

// 工具相关类型
export interface Tool {
  id: number
  name: string
  slug: string
  description: string
  url: string
  logo: string
  screenshot?: string
  categoryId: number
  category?: Category
  tags?: Tag[]
  views: number | string
  upvotes: number | string
  rating: number | string
  reviewCount?: number
  isFree: boolean
  pricing?: string
  isPremium: boolean
  isFeatured: boolean
  isSponsored: boolean
  createdAt: string
  updatedAt: string
  
  // 新增字段：详细信息
  screenshots?: string[]
  useCases?: string
  features?: string[]
  pros?: string[]
  cons?: string[]
  docsUrl?: string
  videoUrl?: string
  githubUrl?: string
  recommendation?: string
  relatedLinks?: Array<{ title: string; url: string }>
}

// 分类相关类型
export interface Category {
  id: number
  name: string
  slug: string
  description?: string
  icon?: string
  order: number
  sortOrder?: number
  reviewCount?: number
  toolCount?: number
  tools?: Tool[]
  createdAt?: string
  updatedAt?: string
}

// 标签相关类型
export interface Tag {
  id: number
  name: string
  slug: string
  toolCount?: number
  createdAt?: string
  updatedAt?: string
}

// 订阅计划类型
export interface SubscriptionPlan {
  type: 'basic' | 'premium'
  name: string
  duration: number // 月数
  price: number
  originalPrice?: number
  features: string[]
}

// 收藏相关类型
export interface Favorite {
  id: number
  userId: number
  toolId: number
  tool?: Tool
  createdAt: string
}

// 查询工具参数
export interface QueryToolsParams {
  page?: number
  limit?: number
  categoryId?: number
  search?: string
  sortBy?: 'createdAt' | 'views' | 'upvotes' | 'rating'
  order?: 'ASC' | 'DESC'
}

// 工具列表响应
export interface ToolsResponse {
  data: Tool[]
  total: number
  page: number
  limit: number
  totalPages: number
}

// 认证响应
export interface AuthResponse {
  token: string
  user: User
}

// API 响应基础类型
export interface ApiResponse<T = any> {
  success: boolean
  data?: T
  message?: string
  error?: string
}

// 收藏检查响应
export interface FavoriteCheckResponse {
  isFavorited: boolean
}

// 评论相关类型
export interface Review {
  id: number
  toolId: number
  userId: number
  rating: number
  performanceRating?: number
  priceRating?: number
  easeOfUseRating?: number
  documentationRating?: number
  content: string
  title?: string
  useCase?: string
  teamSize?: string
  usageDuration?: string
  helpfulCount: number
  notHelpfulCount: number
  status: 'pending' | 'approved' | 'rejected'
  isVerifiedPurchase: boolean
  isFeatured: boolean
  createdAt: string
  updatedAt: string
  user?: User
  tool?: Tool
}

// 查询评论参数
export interface QueryReviewsParams {
  toolId?: number
  userId?: number
  status?: 'pending' | 'approved' | 'rejected'
  sortBy?: 'latest' | 'oldest' | 'highest' | 'lowest' | 'helpful'
  page?: number
  limit?: number
  minRating?: number
  maxRating?: number
}

// 评论列表响应
export interface ReviewsResponse {
  data: Review[]
  meta: {
    total: number
    page: number
    limit: number
    totalPages: number
  }
}

// 文章相关类型
export interface Article {
  id: number
  title: string
  slug: string
  excerpt?: string
  content: string
  contentHtml?: string
  coverImage?: string
  authorId: number
  author?: User
  category?: string
  tags?: string[]
  status: 'draft' | 'published' | 'archived'
  isFeatured: boolean
  views: number
  likes: number
  metaTitle?: string
  metaDescription?: string
  metaKeywords?: string[]
  publishedAt?: string
  createdAt: string
  updatedAt: string
}

export interface QueryArticlesParams {
  page?: number
  limit?: number
  category?: string
  tag?: string
  status?: 'draft' | 'published' | 'archived'
  search?: string
  sortBy?: 'latest' | 'oldest' | 'popular' | 'trending'
  authorId?: number
}

export interface ArticlesResponse {
  data: Article[]
  total: number
  page: number
  limit: number
  totalPages: number
}

// 评分统计
export interface RatingStats {
  averageRating: number
  totalReviews: number
  ratingDistribution: {
    [key: number]: number
    5: number
    4: number
    3: number
    2: number
    1: number
  }
  dimensionRatings: {
    performance: number
    price: number
    easeOfUse: number
    documentation: number
  }
}

